package com.nit.lab.controller.ship;

import com.nit.lab.dto.utils.OpResultDTO;
import com.nit.lab.mapper.ship.ShipPortMapper;
import com.nit.lab.mapper.ship.ShipPortStatusMapper;
import com.nit.lab.mapper.ship.ShipTypeMapper;
import com.nit.lab.service.ship.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
/**
 * @Description:
 * @Author: zmh
 * @Data: 2021/2/19
 */
@RestController
@RequestMapping(value = "/api/shipDetail")
public class ShipDetailController {
    @Resource
    private ShipCategoryService shipCategoryService;
    @Resource
    private ShipCountryService shipCountryService;
    @Resource
    private ShipEpidemicTypeService shipEpidemicTypeService;
    @Resource
    private ShipEpidemicGradeService shipEpidemicGradeService;
    @Resource
    private ShipPortService shipPortService;
    @Resource
    private ShipTypeService shipTypeService;;
    @Resource
    private ShipPortStatusService shipPortStatusService;

    private final Logger logger = LoggerFactory.getLogger(ShipDetailController.class);
    /**
     * 查询船舶出入类型
     * @return
     */
    @PostMapping(value = "/list4shipCategory")
    public OpResultDTO list4shipCategory() {
        OpResultDTO opResultDTO = new OpResultDTO();
        try {
            opResultDTO.setMessage("success");
            opResultDTO.setResult(shipCategoryService.list4shipCategory());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.toString());
            opResultDTO.setMessage("error");
            opResultDTO.setResult("获取船舶出入类型失败！");
        }
        return opResultDTO;
    }
    /**
     * 查询船舶出入类型
     * @return
     */
    @PostMapping(value = "/list4shipCountry")
    public OpResultDTO list4shipCountry() {
        OpResultDTO opResultDTO = new OpResultDTO();
        try {
            opResultDTO.setMessage("success");
            opResultDTO.setResult(shipCountryService.list4shipCountry());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.toString());
            opResultDTO.setMessage("error");
            opResultDTO.setResult("获取船舶国籍失败！");
        }
        return opResultDTO;
    }
    /**
     * 查询船舶类型
     * @return
     */
    @PostMapping(value = "/list4shipType")
    public OpResultDTO list4shipType() {
        OpResultDTO opResultDTO = new OpResultDTO();
        try {
            opResultDTO.setMessage("success");
            opResultDTO.setResult(shipTypeService.list4shipType());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.toString());
            opResultDTO.setMessage("error");
            opResultDTO.setResult("获取船类型失败！");
        }
        return opResultDTO;
    }
    /**
     * 查询港口
     * @return
     */
    @PostMapping(value = "/list4shipPort")
    public OpResultDTO list4shipPort() {
        OpResultDTO opResultDTO = new OpResultDTO();
        try {
            opResultDTO.setMessage("success");
            opResultDTO.setResult(shipPortService.list4shipPort());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.toString());
            opResultDTO.setMessage("error");
            opResultDTO.setResult("获取港口信息失败！");
        }
        return opResultDTO;
    }
    /**
     * 查询在港信息
     * @return
     */
    @PostMapping(value = "/list4shipPortStatus")
    public OpResultDTO list4shipPortStatus() {
        OpResultDTO opResultDTO = new OpResultDTO();
        try {
            opResultDTO.setMessage("success");
            opResultDTO.setResult(shipPortStatusService.list4shipPortStatus());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.toString());
            opResultDTO.setMessage("error");
            opResultDTO.setResult("获取船舶在港信息失败");
        }
        return opResultDTO;
    }
    /**
     * 查询涉疫等级
     * @return
     */
    @PostMapping(value = "/list4shipEpidemicGrade")
    public OpResultDTO list4shipEpidemicGrade() {
        OpResultDTO opResultDTO = new OpResultDTO();
        try {
            opResultDTO.setMessage("success");
            opResultDTO.setResult(shipEpidemicGradeService.list4shipEpidemicGrade());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.toString());
            opResultDTO.setMessage("error");
            opResultDTO.setResult("获取船舶涉疫等级失败！");
        }
        return opResultDTO;
    }
    /**
     * 查询涉疫类型
     * @return
     */
    @PostMapping(value = "/list4shipEpidemicType")
    public OpResultDTO list4shipEpidemicType() {
        OpResultDTO opResultDTO = new OpResultDTO();
        try {
            opResultDTO.setMessage("success");
            opResultDTO.setResult(shipEpidemicTypeService.list4shipEpidemicType());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.toString());
            opResultDTO.setMessage("error");
            opResultDTO.setResult("获取船舶涉疫类型失败！");
        }
        return opResultDTO;
    }




}
